from rest_framework.viewsets import ModelViewSet
from system_config.models import Credential
from system_config.serializers import CredentialSerializer
from rest_framework import filters
from django_filters.rest_framework import DjangoFilterBackend
# from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated


class CredentialViewSet(ModelViewSet):
    queryset = Credential.objects.all()
    serializer_class = CredentialSerializer
    filter_backends = [filters.SearchFilter, filters.OrderingFilter, DjangoFilterBackend]
    search_fields = ("name",)
    filterset_fields = ("name",)
    ordering_fields = ("id",)
    # 认证&权限配置
    # authentication_classes = [SessionAuthentication]
    permission_classes = [IsAuthenticated]
